<%@ page language="java" pageEncoding="UTF-8" contentType="text/html; charset=UTF-8" %>
<%@ include file="/WEB-INF/views/common/taglibs.jsp" %>
<%@ include file="/WEB-INF/views/common/head.jsp" %>

<html>
<head>

    <meta http-equiv="Content-type" content="text/html; charset=utf-8">
    <meta content="type" http-equiv="application/x-www-form-urlencoded"/>
    <meta http-equiv="Cache-Control" content="no-cache, must-revalidate">
    <meta http-equiv="expires" content="Wed, 26 Feb 1997 08:21:57 GMT">
    <meta content="black" name="apple-mobile-web-app-status-bar-style">
    <meta content="telephone=no" name="format-detection">
    <meta name="viewport"
          content="width=device-width, initial-scale=1.0, maximum-scale=1.0, minimum-scale=1.0, user-scalable=0">
    <meta name="apple-mobile-web-app-capable" content="yes"/>
    <META HTTP-EQUIV="Pragma" CONTENT="no-cache">
    <meta http-equiv="X-UA-Compatible" content="IE=edge"/>
    <meta name="screen-orientation" content="portrait">
    <meta name="x5-orientation" content="portrait">
    <meta name="full-screen" content="yes">
    <meta name="x5-fullscreen" content="true">
    <meta name="browsermode" content="application">
    <meta name="x5-page-mode" content="app">
    <link rel="shortcut icon" href="favicon.ico"/>
    <link rel="stylesheet" href="${webRoot}static/app/css/history_common.css?t=1">
    <link rel="stylesheet" href="${webRoot}static/app/css/history_order.css?t=1">

    <script type="text/javascript" src="${webRoot }static/js/jquery/jquery-1.11.3.min.js"></script>
    <script type="text/javascript" src="${webRoot }static/js/jquery/jquery-jtemplates.js"></script>
    <script type="text/javascript" src="${webRoot }static/js/jquery/jquery.form.js"></script>
    <link rel="stylesheet" href="${webRoot }static/common/layer_mobile/need/layer.css"/>
    <script type="text/javascript" src="${webRoot }static/common/layer_mobile/layer.js"></script>


    <title>历史订单</title>
    <style>
        .popup-bg {
            position: fixed;
            display: none;
            top: 0;
            left: 0;
            width: 100%;
            z-index: 10;
            background-color: rgba(0, 0, 0, .5)
        }

        .popup-bg > div {
            position: absolute;
            width: 88.888888%;
            height: 10.25em;
            top: 0;
            right: 0;
            bottom: 0;
            left: 0;
            border-radius: .5em;
            margin: auto;
        }

        .popup-s-headering {
            display: block;
            width: 100%;
            padding: 3.125em 0;
            border-bottom: .1875em solid #E5E5E5;
            border-top-left-radius: .125em;
            border-top-right-radius: .125em;
            text-align: center;
            background-color: white;
            font-size: .9375em;
            color: #666;
        }

        .popup-s-btn {
            display: block;
            width: 100%;
            height: 2.75em;
            border-bottom-left-radius: .125em;
            border-bottom-right-radius: .125em;
            font-size: 1.125em;
            line-height: 2.75em;
            text-align: center;
            background-color: white;
            color: #666;
        }

        .popup-s-btn:active {
            background-color: #f8f8f8;
        }
    </style>
</head>
<body>
<section>
    <div id="contentid">
         <textarea id="template-items" style="display:none">
        <div>
            <div id="h_t_i" class="w-d">
                <span class="b-b"><b></b></span>
                <div class="t-p"><span class="tp-t">近一个月订单&nbsp;</span>
                    <%--<span class="tp-i">￥</span><span--%>
                        <%--class="tp-n"> {$T.total}</span>--%>
                </div>
            </div>
            <div id="h_o_d">
                  {#foreach $T.vo as vos}
                <div class="o-i-d" data-id="{$T.vos.hyVO.orderid}"><b></b> <span class="ho-t-i"><span>{$T.vos.hyVO.createtime}</span>&nbsp;<span></span></span>
                    <div class="ho-o-i-d">
                        {#if $T.vos.hyVO.state== '未支付'}<i class="payed-icon refunding"></i>
                                {#elseif  $T.vos.hyVO.state== '订单已完成'}<i class="payed-icon"></i>
                        {#elseif  $T.vos.hyVO.state== '订单已关闭'}<i class="payed-icon refunding"></i>{#/if}

                        <div class="ho-o-s"><span class="ho-o-c-d">{$T.vos.hyVO.state}</span></div>
                        <div class="ho-o-d-i-d" onclick="loadorderinfo('{$T.vos.hyVO.orderid}',event);"><img
                                class="s-img" src="${webRoot}static/{$T.vos.infosVOs[0].picurl}"
                                alt="餐厅logo">
                            <div class="s-d-info"><span class="ho-o-d-s-n">{$T.vos.infosVOs[0].foodname}, {$T.vos.infosVOs[1].foodname}...</span>
                                <div class="ho-o-d-s-tr"><span>总价</span><span>￥</span><span>{$T.vos.hyVO.totalprices}</span></div>
                            </div>
                        </div>
                    </div>
                </div>
                {#/for}
            </div>
        </div>

             </textarea>
    </div>
    <footer class="footer-nav" id="weichat_navigator">
        <div class="footer-nav-div" onclick="handleShowWare()">
            <ul class="online-ul footer-nav-ul">
                <li class="online-icon"></li>
                <li class="text-li">点单</li>
            </ul>
        </div>
        <div class="footer-nav-div" onclick="showhisOrder()">
            <ul class="footer-nav-ul now-history-ul">
                <li class="history-icon"></li>
                <li class="text-li">历史订单</li>
            </ul>
        </div>
        <%--<div class="footer-nav-div" onclick="showUserInfo()">--%>
            <%--<ul class="personal-ul footer-nav-ul">--%>
                <%--<li class="personal-icon"></li>--%>
                <%--<li class="text-li">个人中心</li>--%>
            <%--</ul>--%>
        <%--</div>--%>

    </footer>
</section>
</body>
<script type="text/javascript">
    $(getTemplate())
    function getTemplate() {
        var loading = layer.open({type: 2});
        $.ajax({
            type: "POST",
            url: '${webRoot }/index/getOrders',
            data: {'openId': '${openId}'},
            dataType: "json",
            beforeSend: function () {

                //设置模板
                $("#contentid").setTemplateElement("template-items");
                $("#contentid").processTemplate({});
            },
            success: function (data) {
                console.log(data)
                if (data.result) {
                    // 填充数据并展示
                    $("#contentid").processTemplate(data.data);
                    //绑定点击事件
                    $(".o-i-d").click(function () {
                        var id = $(this).attr("data-id");
                        window.location.href = '${webRoot}index/pay?orderid=' + id + '&openId=${openId}';
                    });
                } else {
                    alert("error")
                }
                layer.close(loading)
            }
        });
    }
    function handleShowWare() {
        window.location.href = '${webRoot}index/show?openId=${openId}';
    }

</script>
</html>